home *** CD-ROM | disk | FTP | other *** search
- #!perl
-
- # mtx2html.pl
- # MTX to HTML Converter
- # Version 1.5.5 (1/18/97)
- # Richard Rathe <rrathe@dean.med.ufl.edu>
- # http://www.med.ufl.edu/medinfo/mtx/
- # Copyright 1996 by Richard Rathe
-
- # Revision History:
- # 8/1/96 - 1.5 - initial release
- # 9/1/96 - 1.5.1 - fixed minor DTD problems
- # 9/15/96 - 1.5.2 - fixed parent quiz page links
- # 10/1/96 - 1.5.3 - minor changes and fixes
- # 1/1/97 - 1.5.4 - added embedded movies, big, small, super, sub, and non print
- # 1/18/97 - 1.5.5 - added hidden movies (audio only), about and keyword meta info
-
- $mtxinfo = "<!-- This file was created using mtx2html.pl v1.5.5 by Richard Rathe. -->";
- $dtdinfo = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">";
- $movinfo = "WIDTH=250 HEIGHT=204 AUTOPLAY=\"true\" PLUGINSPAGE=\"http://quicktime.apple.com\"";
-
- @letters = ('#','A','B','C','D','E','F','G','H','I','J','K',
- 'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
-
- ### process file(s)
-
- print "Starting MTX2HTML v1.5.5...\n";
-
- while(@ARGV > 0) # drag and drop file(s) on Mac droplet
- { # or from command line under MSDOS, UNIX
- $infile = shift(@ARGV);
- $outfile = $infile;
- $outfile =~ s/(.*\.)(.*)/$1html/;
- if($infile =~ /.*\.mtx/i) {&mtx2html($infile,$outfile);}
- else { print " skip: $infile\n"; }
- }
-
- print "\n";
-
- ### main program ###
-
- sub mtx2html # requires two args:
- { # path:infile
- @toc = (); # path:outfile
- %info = ();
- $main = "";
- $head = "";
- $tail = "";
- $navi = "";
- $tocf = "";
- $akey = "";
- $qtxt = "";
- $stxt = "";
- $para = "";
- $path = "";
- $hcount = 0;
- $lcount = 0;
- $tcount = 0;
- $pcount = 0;
- $qcount = 0;
- $acount = 0;
-
- $_[1] =~ /(.*:)(.*)\.html/; $qpath = $1; $qfile = $2;
-
- open(INFILE,$_[0]) || die "Can't open input file $_[0].\n";
- print "reading: $_[0]\n";
-
- ### parse file one line at a time
-
- while (<INFILE>) {
- /.*\n/ && chop; # last line may not have a \n
-
- s/&/&/g; # fix special chars
- s/</</g;
- s/>/>/g;
- s/\"/"/g;
-
- if($_ eq "") # blank line
- {
- &flush_quest;
- &flush_para;
- &flush_pref;
- #&flush_list; # allow blank lines in lists
- #&flush_table; # allow blank lines in tables
- }
- elsif (/^%%.*/) # comment (%%)
- {
- # do nothing
- }
- elsif (/^%(\S+)\s*(.*)/) # page info (%)
- {
- $key = $1;
- $key =~ tr/a-z/A-Z/;
- $info{$key} = $2;
- if ($key eq "IMAGES") { $path = $2; }
- }
- elsif (/(^#+)(.*)/) # heading (#)
- {
- &flush_quest;
- &flush_para;
- &flush_list;
- &flush_table;
- &flush_pref;
- $x = length($1) + 1;
- $htext = $2;
-
- if ($htext =~ /^\$(.*)/) { $htext = $1; $align = " ALIGN=center"; }
- else { $align = ""; }
-
- if ($htext =~ /(.*)#=(\S*)/) { $htext = $1; $h1 = "<A NAME=\"$2\">"; $h2 = "<\/A>"; }
- else { $h1 = ""; $h2 = ""; }
-
- if ($htext =~ /^!(.*)/)
- {
- $info{'HEADING'} = $1;
- $main .= "\n!HEAD!\n\n";
- }
- elsif ($htext =~ /(.*)#(\S*)/)
- {
- $hcount++;
- $toc[$hcount-1] .= "$x|<A HREF=\"$2\">$1<\/A>";
- }
- else
- {
- $hcount++;
- if ($tocf eq "") { $main .= "\n!TOC!\n"; $tocf = "toc"; }
- if (defined $info{'LAYOUT'} and $info{'LAYOUT'} eq "slide")
- {
- $main .= "\n<<H$x$align><A NAME=\"AA$hcount\">$h1$htext$h2<\/A></H$x>\n\n";
- $toc[$hcount-1] = "<A HREF=\"$qfile$hcount.html\">$htext<\/A>";
- }
- else
- {
- $main .= "\n<H$x$align><A NAME=\"AA$hcount\">$h1$htext$h2<\/A></H$x>\n\n";
- $toc[$hcount-1] = "$x|<A HREF=\"#AA$hcount\">$htext<\/A>";
- }
- }
- }
- elsif (/^\|.*/) # table (|)
- {
- if (/^\|-.*/) { &flush_table; }
- else
- {
- &flush_para;
- if (!$caption) { $caption = "$&"; } else { $table[$tcount++] = "$&"; }
- }
- }
- elsif (/(^\s+)(.*)/) # list (space or tab)
- {
- &flush_para;
- if ($acount == 0)
- {
- $x = length($1);
- $list[$lcount++] = "$x $2";
- }
- else { $atxt[$acount] .= "\n<P>$2"; }
- }
- elsif (/^\?(.*)/) # question (?)
- {
- &flush_quest;
- &flush_para;
- &flush_list;
- &flush_table;
- &flush_pref;
- $qcount++;
- $1 =~ /(\w*)\??(\w*)/;
- $qkey = $1;
- $qmod = $2;
- $qkey =~ tr/a-z/A-Z/;
- $qmod =~ tr/a-z/A-Z/;
- if ($info{'LAYOUT'} =~ /feedback/i) { $qmod = ""; }
- if ($info{'LAYOUT'} =~ /nofeedback/i) { $qmod = "NONE"; }
- if ($info{'LAYOUT'} =~ /print/i) { $qmod = "NONE"; }
- if ($info{'QUIZCGI'}) { $qmod = "QUIZ"; }
-
- if ($info{'FILE'}) { $rfile = "$info{'FILE'}.html"; }
- else { $rfile = "$qfile.html"; }
-
- $qtxt .= "$dtdinfo\n<HTML>\n\n$mtxinfo\n\n<HEAD>\n<TITLE>Feedback for Question $qcount</TITLE></HEAD>\n<BODY>\n\n";
- $qtxt .= "<A HREF=\"$rfile\">$info{'TITLE'}</A>\n";
- $qtxt .= "<H1>Question $qcount Feedback</H1>\n";
- $x = length($qkey);
- if ($x == 1) { $temp = "Single Best Answer" } else { $temp = "Best $x Answers" }
- $main .= "<P><STRONG><BIG>Question $qcount - $temp</BIG></STRONG>\n";
- }
- elsif (/^@(.*)/) # answer (@)
- {
- &flush_para;
- $acount++;
- $temp = "$letters[$acount])";
- $atxt[$acount] = "$temp $1";
- $x = length($qkey);
- if ($acount == 1) { $main .= "<BLOCKQUOTE>\n"; }
-
- if ($qmod eq "QUIZ")
- {
- if ($x == 1)
- { $main .= "<P><INPUT TYPE=radio NAME=q$qcount VALUE=a$acount>$1\n"; }
- else
- { $main .= "<P><INPUT TYPE=checkbox NAME=q$qcount VALUE=a$acount>$1\n"; }
-
- $y = index($qkey, $letters[$acount]);
-
- if ($y >= 0 && $akey =~ /q$qcount=/)
- { chop($akey); $akey .= ":a$acount\n"; }
- elsif ($y >= 0)
- { $akey .= "q$qcount=a$acount\n"; }
- elsif ($x > 1 && $akey =~ /q$qcount=/)
- { chop($akey); $akey .= ":x\n"; }
- elsif ($x > 1)
- { $akey .= "q$qcount=x\n"; }
- }
- elsif ($qmod eq "")
- {
- $main .= "<P><A HREF=\"$qfile$qcount$letters[$acount].html\">$temp $1</A>\n";
-
- if (index($qkey, $letters[$acount]) < 0)
- {
- if ($x == 1) { $atxt[$acount] .= "<P><A HREF=\"$qfile$qcount$qkey.html\"><STRONG><BIG>Sorry...</BIG></STRONG></A>"; }
- else { $atxt[$acount] .= "<P><STRONG><BIG>Sorry...</BIG></STRONG>"; }
- }
- else
- {
- if ($x == 1) { $atxt[$acount] .= "<P><STRONG><BIG>Correct!</BIG></STRONG>"; }
- else { $atxt[$acount] .= "<P><STRONG><BIG>Correct, but there are more...</BIG></STRONG>"; }
- }
- }
- else { $main .= "<P>$temp $1\n"; }
- }
- elsif (/^-.*/) # horizontal rule (-)
- {
- &flush_list;
- &flush_table;
- &flush_pref;
- $para .= "\n<HR SIZE=1>\n";
- }
- elsif (/^''(.*)/) # pull quote ('')
- {
- &flush_para;
- &flush_list;
- &flush_table;
- &flush_pref;
- $main .= "<P><HR SIZE=1><CENTER><STRONG><BIG>$1</BIG></STRONG></CENTER><HR SIZE=1>\n";
- }
- elsif (/^=(.*)/) # preformatted text (=)
- {
- &flush_para;
- &flush_list;
- &flush_table;
- $pref[$pcount++] = $1;
- }
- else # other stuff
- {
- &flush_list;
- &flush_table;
- &flush_pref;
- if($para eq "") { $para = $_; }
- else { $para .= " $_"; }
- }
- }
-
- &flush_quest; # flush everything just to be sure
- &flush_para;
- &flush_list;
- &flush_table;
- &flush_pref;
-
- ### fix up page info
-
- if (!$info{'MTX'})
- { print "WARNING: The format of this file is unknown!\n"; }
- elsif ($info{'MTX'} < 1.5)
- { print "WARNING: The format of this file ($info{'MTX'}) is not current!\n"; }
-
- if ($info{'FILE'}) { $_[1] =~ s/(.*:).*/$1$info{'FILE'}\.html/; }
- else { $_[1] =~ /.*:(.*)\.html/; $info{'FILE'} = $1; }
-
- if (!$info{'TITLE'}) { $info{'TITLE'} = $info{'FILE'}; }
-
- if (!$info{'HEADING'}) { $info{'HEADING'} = $info{'TITLE'}; }
-
- if ($info{'HEADING'} =~ /(^!\w*$)/) { $info{'HEADING'} = "$1 $info{'TITLE'}"; }
-
- if (!$info{'AUTHOR'}) { $info{'AUTHOR'} = $info{'AUTHURL'}; }
-
- if (!$info{'CONTACT'}) { $info{'CONTACT'} = $info{'CONTURL'}; }
-
- if (!$info{'VERSION'}) { $info{'VERSION'} = $info{'VERSURL'}; }
-
- if ($info{'HOMEURL'} && !$info{'HOME'}) { $info{'HOME'} = "Home Page" }
-
- if ($info{'PARENTURL'} && !$info{'PARENT'}) { $info{'PARENT'} = "Parent Page" }
-
- if ($info{'INDEXURL'} && !$info{'INDEX'}) { $info{'INDEX'} = "Index Page" }
-
- if ($info{'PREVURL'} && !$info{'PREV'}) { $info{'PREV'} = "Previous Page" }
-
- if ($info{'NEXTURL'} && !$info{'NEXT'}) { $info{'NEXT'} = "Next Page" }
-
- if ($info{'LAYOUT'} eq "print")
- { $info{'OUTLINE'} = "none"; $info{'COUNTER'} = "";
- $info{'HOMEURL'} = ""; $info{'PARENTURL'} = ""; $info{'INDEXURL'} = "";
- $info{'PREVURL'} = ""; $info{'NEXTURL'} = ""; }
-
- if ($info{'LAYOUT'} eq "slide") { $info{'OUTLINE'} = "slide"; }
-
- if ($info{'REFRESH'} && $info{'LAYOUT'} eq "slide")
- { $info{'REFRESH'} =~ s/^(\d+)$/<META HTTP-EQUIV=\"refresh\" CONTENT=\"$1; URL=/; }
- elsif ($info{'REFRESH'} =~ /(\d+)\s+(.+)/)
- { $info{'REFRESH'} =~ s/(\d+)\s+(.+)/<META HTTP-EQUIV=\"refresh\" CONTENT=\"$1; URL=$2\">/; }
- elsif ($info{'REFRESH'})
- { $info{'REFRESH'} =~ s/^(\d+)$/<META HTTP-EQUIV=\"refresh\" CONTENT=\"$1\">/; }
-
- if ($info{'LOGO'} =~ /(^\$?)(.+)/) { $info{'HEADING'} = "$1!$2"; }
-
- if ($info{'QUIZCGI'}) { $info{'STAMP'} = time; $info{'STAMP'} =~ s/\d*(\d\d\d\d$)/$1/; }
-
- if ($info{'QUIZLIST'}) { $info{'QUIZLIST'} .= ".lst"; }
-
- if ($info{'QUIZTYPE'} && !$info{'LAYOUT'}) { $info{'LAYOUT'} = "results"; }
-
- if ($info{'ABSTRACT'})
- { $info{'ABSTRACT'} = "<META NAME=\"description\" CONTENT=\"$info{'ABSTRACT'}\">"; }
-
- if ($info{'KEYWORDS'})
- { $info{'KEYWORDS'} = "<META NAME=\"keywords\" CONTENT=\"$info{'KEYWORDS'}\">"; }
-
- ### process embedded tags
-
- $main = &process_tags($main);
-
- ### build navigation buttons
-
- if ($info{'HOMEURL'} eq 'none') { $navi .= "$info{'HOME'} | "; }
- elsif ($info{'HOMEURL'}) { $navi .= "<A HREF=\"$info{'HOMEURL'}\">$info{'HOME'}</A> | "; }
-
- if ($info{'PARENTURL'} eq 'none') { $navi .= "$info{'PARENT'} | "; }
- elsif ($info{'PARENTURL'}) { $navi .= "<A HREF=\"$info{'PARENTURL'}\">$info{'PARENT'}</A> | "; }
-
- if ($info{'INDEXURL'} eq 'none') { $navi .= "$info{'INDEX'} | "; }
- elsif ($info{'INDEXURL'}) { $navi .= "<A HREF=\"$info{'INDEXURL'}\">$info{'INDEX'}</A> | "; }
-
- if ($info{'PREVURL'} eq 'none') { $navi .= "$info{'PREV'} | "; }
- elsif ($info{'PREVURL'}) { $navi .= "<A HREF=\"$info{'PREVURL'}\">$info{'PREV'}</A> | "; }
-
- if ($info{'NEXTURL'} eq 'none') { $navi .= "$info{'NEXT'} | "; }
- elsif ($info{'NEXTURL'}) { $navi .= "<A HREF=\"$info{'NEXTURL'}\">$info{'NEXT'}</A> | "; }
-
- if ($navi) { chop($navi); chop($navi); chop($navi); $navi .= "\n"; }
-
- ### build page header
-
- $head = "$dtdinfo\n<HTML>\n\n$mtxinfo\n\n<HEAD>\n";
- if ($info{'REFRESH'} && $info{'LAYOUT'} ne "slide") { $head .= "$info{'REFRESH'}\n"; }
-
- if ($info{'ABSTRACT'}) { $head .= "$info{'ABSTRACT'}\n"; }
- if ($info{'KEYWORDS'}) { $head .= "$info{'KEYWORDS'}\n"; }
-
- $head .= "<TITLE>$info{'TITLE'}</TITLE>\n</HEAD>\n\n";
-
- if ($info{'WATERMARK'}) { $head .= "<BODY BACKGROUND=\"$path$info{'WATERMARK'}.gif\">\n"; }
- elsif ($info{'COLORS'}) { $head .= "<BODY $info{'COLORS'}>\n"; }
- else { $head .= "<BODY>\n"; }
-
- if ($navi) { $head .= $navi . "<HR SIZE=1>\n"; }
-
- if ($info{'HEADING'} =~ /^\$(.*)/) { $info{'HEADING'} = $1; $align = " ALIGN=center"; }
- else { $align = ""; }
-
- $info{'HEADING'} =~ s/^!(\w*) ?(.*)/<IMG SRC=\"$path$1.gif\" ALT=\"$2\">/i;
-
- if ($main =~ /!HEAD!/) { $main =~ s/!HEAD!/<H1$align>$info{'HEADING'}<\/H1>/; }
- else { $head .= "<H1$align>$info{'HEADING'}</H1>\n"; }
-
- if ($info{'QUIZCGI'}) { $head .= "<FORM METHOD=post ACTION=\"$info{'QUIZCGI'}\">\n"; }
-
- ### build page footer
-
- if ($info{'QUIZCGI'})
- {
- $tail .= "\n<HR SIZE=1>\n";
- if ($info{'QUIZLIST'})
- { $tail .= " ID Code: <INPUT SIZE=15 TYPE=password NAME=id> \n"; }
- $tail .= "<INPUT TYPE=submit VALUE=\"Submit Answers\"> <INPUT TYPE=reset VALUE=\"Reset Form\">\n";
- $tail .= "<INPUT TYPE=hidden NAME=stamp VALUE=$info{'STAMP'}>\n";
- $tail .= "<INPUT TYPE=hidden NAME=number VALUE=$qcount>\n";
- }
-
- if ($info{'COUNTER'})
- {
- $info{'COUNTER'} =~ /(\w* \d*, \d*) +(.*)/;
- $tail .= "\n<HR SIZE=1>\n<EM>You are visitor <IMG SRC=\"$2\" ALIGN=ABSMIDDLE> since $1.</EM>\n";
- }
-
- if ($info{'LAYOUT'} eq "cover")
- {
- $tail .= "\n<TT>";
- }
- else
- {
- $ts = ×tamp;
- $tail .= "\n<HR SIZE=1>\n<TT>";
-
- if ($info{'CREATED'})
- {
- $tail .= "\n <STRONG>Created:</STRONG> $info{'CREATED'}";
- $tail .= "\n <STRONG>Modified:</STRONG> $ts";
- }
- else { $tail .= "\n <STRONG>Updated:</STRONG> $ts"; }
-
- if ($info{'EXPIRES'})
- {
- $tail .= "\n <STRONG>Expires:</STRONG> $info{'EXPIRES'}";
- }
- }
-
- if ($info{'VERSURL'})
- {
- $tail .= "\n<BR> <STRONG>Version:</STRONG> <A HREF=\"$info{'VERSURL'}\">$info{'VERSION'}</A>";
- }
- elsif ($info{'VERSION'})
- {
- $tail .= "\n<BR> <STRONG>Version:</STRONG> $info{'VERSION'}";
- }
-
- if ($info{'AUTHURL'})
- {
- if($info{'AUTHURL'} =~ /.+@.+/) { $info{'AUTHURL'} = "mailto:" . $info{'AUTHURL'}; }
- $tail .= "\n<BR> <STRONG>Author:</STRONG> <A HREF=\"$info{'AUTHURL'}\">$info{'AUTHOR'}</A>";
- }
- elsif ($info{'AUTHOR'})
- {
- $tail .= "\n<BR> <STRONG>Author:</STRONG> $info{'AUTHOR'}";
- }
-
- if ($info{'CONTURL'})
- {
- if($info{'CONTURL'} =~ /.+@.+/) { $info{'CONTURL'} = "mailto:" . $info{'CONTURL'}; }
- $tail .= "\n<BR> <STRONG>Contact:</STRONG> <A HREF=\"$info{'CONTURL'}\">$info{'CONTACT'}</A>";
- }
- elsif ($info{'CONTACT'})
- {
- $tail .= "\n<BR> <STRONG>Contact:</STRONG> $info{'CONTACT'}";
- }
-
- if ($info{'PATH'})
- {
- $tail .= "\n<BR> <STRONG>Location:</STRONG> <A HREF=\"$info{'PATH'}$info{'FILE'}.html\">$info{'PATH'}$info{'FILE'}.html</A>";
- }
-
- if ($info{'COPYURL'})
- {
- $tail .= "\n<BR><STRONG>Copyright:</STRONG> <A HREF=\"$info{'COPYURL'}\">$info{'COPYRIGHT'}</A>";
- }
- elsif ($info{'COPYRIGHT'})
- {
- $tail .= "\n<BR><STRONG>Copyright:</STRONG> $info{'COPYRIGHT'}";
- }
-
- if ($navi) { $tail .= "\n</TT>\n<HR SIZE=1>\n" . $navi; }
- else { $tail .= "\n</TT>\n"; }
-
- if ($info{'QUIZCGI'}) { $tail .= "</FORM>\n"; }
-
- $tail .= "</BODY>\n</HTML>\n";
-
- ### build toc/outline
-
- $temp = "";
-
- if ($info{'OUTLINE'} eq "none" || $toc[0] eq "")
- {
- $toc = "<HR SIZE=1>";
- }
- elsif ($info{'OUTLINE'} eq "slide")
- {
- $toc = "<HR SIZE=1>\n<OL>\n";
-
- foreach $item (@toc) { $toc .= "<LI>$item\n"; }
-
- $toc .= "$temp</OL>\n<HR SIZE=1>\n\n";
- $toc .= "<STRONG>A Note on These Slides: </STRONG>To begin, select any slide from ";
- $toc .= "the list above. Use the controls (< i >) to move forward, backward, or return ";
- $toc .= "to this index. Increase the font size of your browser for optimal viewing.";
-
- if ($x = index($main,"!TOC!"))
- {
- $stxt = substr($main,$x+6);
- $main = substr($main,0,$x+6);
- }
- }
- elsif ($info{'OUTLINE'} eq "long")
- {
- $level = 1;
- foreach $item (@toc)
- {
- # print "$level $item\n";
- $item =~ s/(.*)\|(.*)/<LI>$2/;
- if ($1 == $level) { $temp .= "$item\n"; }
- elsif ($1 > $level) { $temp .= "<UL>\n$item\n"; }
- else
- {
- while($level > $1)
- {
- $level--;
- $temp .= "</UL>\n";
- }
- $temp .= "$item\n";
- }
- $level = $1;
- }
-
- while ($level > 1)
- {
- $level--;
- $temp .= "</UL>\n";
- }
- $toc = "<HR SIZE=1>\n$temp<HR SIZE=1>";
- }
- else
- {
- foreach $item (@toc)
- {
- $item =~ s/(.*)\|(.*)/$2 \| /;
- if ($1 == 2){ $temp .= "$item\n"; }
- }
- chop($temp); chop($temp); chop($temp);
- $toc = "<HR SIZE=1>\n$temp\n<HR SIZE=1>";
- }
-
- if ($main =~ /!TOC!/) { $main =~ s/!TOC!/$toc/; }
-
- ### output page
-
- open(OUTFILE,">$_[1]") || die "Can't open output file $_[1].\n";
- print "writing: $_[1]\n";
-
- print OUTFILE "$head$main$tail";
-
- close(INFILE);
- close(OUTFILE);
-
- MacPerl::SetFileInfo("MOSS", "TEXT", $_[1]); # netscape creator (mac only)
-
- ### output slides
-
- $scount = 0;
- $x = index($stxt,"<<H");
- $stxt = substr($stxt,$x);
- $stxt .= "<<H";
-
- while (($x = index($stxt,"<<H",1)) > -1)
- {
- $temp = substr($stxt,1,$x); $temp =~ s/<P>//; chop($temp);
- $stxt = substr($stxt,$x);
-
- $scount++; $prevnum = $scount-1; $nextnum = $scount+1;
- $file = "$qpath$qfile$scount.html";
- $prev = "$qfile$prevnum.html";
- $next = "$qfile$nextnum.html";
- $refn = "$qfile$nextnum.html";
- if ($scount == 1) { $prev = "$info{'FILE'}.html"; }
- elsif ($scount == $hcount) { $next = "$info{'FILE'}.html"; $refn = $qfile . "1.html"; }
-
- # $picon = "prev.gif"; $iicon = "index.gif"; $nicon = "next.gif";
- # $temp =~ s/.*<H.>(.*)<\/H.><\/A>/<TITLE>$info{'TITLE'} - $1<\/TITLE>\n<\/HEAD>\n<BODY>\n\n<A HREF=\"$prev\"><IMG SRC=\"$path$picon\" ALT=\"Prev\"><\/A><A HREF=\"$qfile.html\"><IMG SRC=\"$path$iicon\" ALT=\"Index\"><\/A><A HREF=\"$next\"><IMG SRC=\"$path$nicon\" ALT=\"Next\"><\/A><CENTER><STRONG>$1<\/STRONG><\/CENTER>\n<HR SIZE=1>\n/i;
-
- if ($info{'REFRESH'}) { $refresh = "$info{'REFRESH'}$refn\">"; }
-
- $controls = "<TT><A HREF=\"$prev\">< <\/A>";
- $controls .= "<A HREF=\"$info{'FILE'}.html\">i<\/A>";
- $controls .= "<A HREF=\"$next\"> ><\/A><\/TT>\n";
- $body = "<BODY BGCOLOR=\"#0102FF\" TEXT=\"#FFFF04\" LINK=\"#00FF02\" ALINK=\"#FFFFFF\" VLINK=\"#00FF02\">";
- $temp = "$dtdinfo\n<HTML>\n\n$mtxinfo\n\n<HEAD>\n$refresh\n" . $temp;
- $temp =~ s/<H.><A.*>(.*)<\/A><\/H.>/<TITLE>$1 - $info{'TITLE'}<\/TITLE>\n<\/HEAD>\n$body\n\n$controls<CENTER><STRONG>$1<\/STRONG><\/CENTER>\n<HR SIZE=4>/i;
- $temp .= "</BODY>\n</HTML>";
-
- open(OUTFILE,">$file") || die "Can't open output file $file.\n";
- print "writing: $file\n";
-
- print OUTFILE $temp;
- close(OUTFILE);
- }
-
- ### output quiz key
-
- if ($info{'QUIZCGI'})
- {
- $file = "$qpath$qfile.key";
- open(OUTFILE,">$file") || die "Can't open output file $file.\n";
- print "writing: $file\n";
-
- print OUTFILE "$info{'TITLE'}\|$ts\|$info{'STAMP'}\|$info{'LAYOUT'}\|$info{'EXPIRES'}\|$info{'QUIZLIST'}\n$akey";
- close(OUTFILE);
- }
- }
-
- ### add paragraph to main text ###
-
- sub flush_para
- {
- if ($para ne "")
- {
- if ($para =~ /^\$(.*)/) { $main .= "<P ALIGN=center>$1\n"; }
- elsif ($para =~ /^\'(.*)/) { $main .= "<BLOCKQUOTE>$1</BLOCKQUOTE>\n"; }
- elsif ($para =~ /^\+(.*)/ && $info{'LAYOUT'} ne "print") { $main .= "<P>$1\n"; }
- elsif ($para =~ /^\+(.*)/ && $info{'LAYOUT'} eq "print") { ; } # do nothing
- else { $main .= "<P>$para\n"; }
-
- if ($qtxt ne "") { $qtxt .= "<P>$para\n"; }
-
- $para = "";
- }
- }
-
- ### add preformatted text to main ###
-
- sub flush_pref
- {
- if (@pref)
- {
- $main .= "<PRE>";
- foreach $item (@pref)
- {
- $main .= "$item\n";
- }
- $main .= "</PRE>\n";
- }
-
- undef @pref;
- $pcount = 0;
- }
-
- ### add list to main text ###
-
- sub flush_list
- {
- $level = 0;
-
- foreach $item (@list)
- {
- $item =~ /(\d) (.)(.*)/;
- $item = $3;
-
- if($2 eq "#") {$stag[$1] = "<OL>"; $etag[$1] = "</OL>"; $itag[$1] = "<LI>"; }
- elsif($2 eq "@") {$stag[$1] = "<OL TYPE=a>"; $etag[$1] = "</OL>"; $itag[$1] = "<LI>"; }
- elsif($2 eq "!") {$stag[$1] = "<OL TYPE=I>"; $etag[$1] = "</OL>"; $itag[$1] = "<LI>"; }
- elsif($2 eq "+") {$stag[$1] = "<DL>"; $etag[$1] = "</DL>"; $itag[$1] = "<DT>"; $item = "<EM>$item</EM>"; }
- elsif($2 eq "-") {$stag[$1] = "<DL>"; $etag[$1] = "</DL>"; $itag[$1] = "<DD>"; }
- else {$stag[$1] = "<UL>"; $etag[$1] = "</UL>"; $itag[$1] = "<LI>"; $item = $2 . $3; }
-
- if ($1 > $level) # start list
- {
- $level = $1;
- $main .= "$stag[$1]\n";
- }
- elsif ($1 < $level) # end list
- {
- while ($1 < $level) { $main .= "$etag[$level--]\n"; }
- }
-
- $main .= "$itag[$1]$item\n"; # list item
- }
-
- while ($level > 0) { $main .= "$etag[$level--]\n"; }
-
- undef @list;
- $lcount = 0;
- }
-
- ### add table to main text ###
-
- sub flush_table
- {
- if (@table)
- {
- $caption =~ s/^\|([^|]*)(.*)/$1/;
- $type = $2;
- $caption =~ s/none//i;
-
- if ($type =~ /(nowide\|noborder|noborder\|nowide)/)
- { $main .= "<CENTER><P><TABLE>\n"; }
- elsif ($type =~ /nowide/)
- { $main .= "<CENTER><P><TABLE BORDER=6 CELLPADDING=2 CELLSPACING=1>\n"; }
- elsif ($type =~ /noborder/)
- { $main .= "<CENTER><P><TABLE WIDTH=\"95%\">\n"; }
- else
- { $main .= "<CENTER><P><TABLE BORDER=6 CELLPADDING=2 CELLSPACING=1 WIDTH=\"95%\">\n"; }
-
- if ($caption)
- { $main .= "<CAPTION><STRONG><EM>" . $caption . "</EM></STRONG></CAPTION>\n"; }
-
- foreach $item (@table)
- {
- $main .= "<TR>";
-
- while ($item)
- {
- $item =~ s/^\|([^|]*)(.*)/$2/;
- $cell = $1;
-
- $cell =~ s/(.*[\S|\*])(\s*$)/$1/;
- $cell =~ s/(^[\*|^]?)(.*)/$2/;
- $tag = $1;
- $cell =~ s/\s*//;
-
- if ($cell =~ /(.*)\\(\d*)/) { $cell = $1; $col = " COLSPAN=$2 ALIGN=center>"; }
- else { $col = ">"; }
-
- if ((!$cell) && ($type =~ /noblanks/)) { $tag = "*"; }
-
- if (($tag eq "*") && $cell) { $main .= "<TH" . $col . $cell . "</TH>"; }
- elsif ($tag eq "*") { $main .= "<TD>" . " " . "</TD>"; }
- elsif ($tag eq "^") { $main .= "<TD VALIGN=top" . $col . $cell . "</TD>"; }
- else { $main .= "<TD" . $col . $cell . "</TD>"; }
- }
- $main .= "</TR>\n";
- }
- $main .= "</TABLE></CENTER>\n";
- }
-
- undef @table;
- undef $caption;
- $tcount = 0;
- }
-
- ### output question feedback files ###
-
- sub flush_quest
- {
- if ($acount > 0)
- {
- $main .= "</BLOCKQUOTE>\n"; # ??dead code??
-
- if ($qmod eq "")
- {
- $cnt = 0;
- $qtxt = &process_tags($qtxt);
-
- while ($acount > $cnt)
- {
- $cnt++;
-
- $file = "$qpath$qfile$qcount$letters[$cnt].html";
-
- open(OUTFILE,">$file") || die "Can't open output file $file.\n";
- print "writing: $file\n";
-
- $atxt[$cnt] = &process_tags($atxt[$cnt]);
-
- print OUTFILE "$qtxt\n<BLOCKQUOTE>\n<P>";
- print OUTFILE "$atxt[$cnt]\n";
- print OUTFILE "</BLOCKQUOTE>\n</BODY>\n</HTML>";
-
- close(OUTFILE);
- }
- }
-
- undef $qtxt;
- undef $qkey;
- undef $qmod;
- undef @atxt;
- $acount = 0;
- }
- }
-
- ### process embedded tags ###
-
- sub process_tags
- {
- $temp = $_[0];
-
- $temp =~ s/{P}/<P>/gi;
- $temp =~ s/{B}/<BR>/gi;
- $temp =~ s/{S}/ /gi;
- $temp =~ s/{C}/<BR CLEAR=all>/gi;
-
- $temp =~ s/{!/<EM>/g; $temp =~ s/!}/<\/EM>/g;
- $temp =~ s/{\*/<STRONG>/g; $temp =~ s/\*}/<\/STRONG>/g;
- $temp =~ s/{@/<TT>/g; $temp =~ s/@}/<\/TT>/g; # F replaces @
-
- $temp =~ s/{F/<TT>/g; $temp =~ s/F}/<\/TT>/g;
- $temp =~ s/{B/<BIG>/g; $temp =~ s/B}/<\/BIG>/g;
- $temp =~ s/{S/<SMALL>/g; $temp =~ s/S}/<\/SMALL>/g;
- $temp =~ s/{P/<SUP>/g; $temp =~ s/P}/<\/SUP>/g;
- $temp =~ s/{N/<SUB>/g; $temp =~ s/N}/<\/SUB>/g;
-
- $temp =~ s/{#([^{}]*@[^{}]*)##}/<A HREF=\"mailto:$1\">$1<\/A>/g;
- $temp =~ s/{#([^{}]*)##}/<A HREF=\"$1\">$1<\/A>/g;
- $temp =~ s/{#([^{}]*)#=([^{}]*)#}/<A NAME=\"$2\">$1<\/A>/g;
- $temp =~ s/{#([^{}]*)#(#[^{}]*)#}/<A HREF=\"$2\">$1<\/A>/g;
- $temp =~ s/{#([^{}#]*)#([^{}]*@[^{}]*)#}/<A HREF=\"mailto:$2\">$1<\/A>/g;
- $temp =~ s/{#([^{}#]*)#([^{}]*)#}/<A HREF=\"$2\">$1<\/A>/g;
-
- $temp =~ s/{=(\w*)=}/<IMG SRC=\"$path$1.gif\">/gi;
- $temp =~ s/{=(\w*) (.*)=}/<IMG SRC=\"$path$1.gif\" ALT=\"$2\">/gi;
- $temp =~ s/{=\$(\w*)=}/<IMG SRC=\"$path$1.gif\" ALIGN=absmiddle>/gi;
- $temp =~ s/{=\$(\w*) (.*)=}/<IMG SRC=\"$path$1.gif\" ALIGN=absmiddle ALT=\"$2\">/gi;
- $temp =~ s/{=\\(\w*)=}/<IMG SRC=\"$path$1.gif\" ALIGN=left>/gi;
- $temp =~ s/{=\\(\w*) (.*)=}/<IMG SRC=\"$path$1.gif\" ALIGN=left ALT=\"$2\">/gi;
- $temp =~ s/{=\/(\w*)=}/<IMG SRC=\"$path$1.gif\" ALIGN=right>/gi;
- $temp =~ s/{=\/(\w*) (.*)=}/<IMG SRC=\"$path$1.gif\" ALIGN=right ALT=\"$2\">/gi;
-
- $temp =~ s/{\+(\w*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\"><\/A>/gi;
- $temp =~ s/{\+(\w*) (.*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\" ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{\+\$(\w*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\" ALIGN=absmiddle><\/A>/gi;
- $temp =~ s/{\+\$(\w*) (.*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\" ALIGN=absmiddle ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{\+\\(\w*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\" ALIGN=left><\/A>/gi;
- $temp =~ s/{\+\\(\w*) (.*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\" ALIGN=left ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{\+\/(\w*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\" ALIGN=right><\/A>/gi;
- $temp =~ s/{\+\/(\w*) (.*)\+}/<A HREF=\"$path$1.jpg\"><IMG SRC=\"$path$1.gif\" ALIGN=right ALT=\"$2\"><\/A>/gi;
-
- $temp =~ s/{-(\w*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\"><\/A>/gi;
- $temp =~ s/{-(\w*) (.*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\" ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{-\$(\w*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\" ALIGN=absmiddle><\/A>/gi;
- $temp =~ s/{-\$(\w*) (.*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\" ALIGN=absmiddle ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{-\\(\w*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\" ALIGN=left><\/A>/gi;
- $temp =~ s/{-\\(\w*) (.*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\" ALIGN=left ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{-\/(\w*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\" ALIGN=right><\/A>/gi;
- $temp =~ s/{-\/(\w*) (.*)-}/<A HREF=\"$path$1L.gif\"><IMG SRC=\"$path$1.gif\" ALIGN=right ALT=\"$2\"><\/A>/gi;
-
- $temp =~ s/{#(\w*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\"><\/A>/gi;
- $temp =~ s/{#(\w*) (.*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\" ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{#\$(\w*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\" ALIGN=absmiddle><\/A>/gi;
- $temp =~ s/{#\$(\w*) (.*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\" ALIGN=absmiddle ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{#\\(\w*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\" ALIGN=left><\/A>/gi;
- $temp =~ s/{#\\(\w*) (.*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\" ALIGN=left ALT=\"$2\"><\/A>/gi;
- $temp =~ s/{#\/(\w*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\" ALIGN=right><\/A>/gi;
- $temp =~ s/{#\/(\w*) (.*)#}/<A HREF=\"$1.html\"><IMG SRC=\"$path$1.gif\" ALIGN=right ALT=\"$2\"><\/A>/gi;
-
- $temp =~ s/{M(\w*)M}/<EMBED SRC=\"$path$1.mov\" $movinfo>/g;
- $temp =~ s/{M\\(\w*)M}/<EMBED SRC=\"$path$1.mov\" ALIGN=left $movinfo>/g;
- $temp =~ s/{M\/(\w*)M}/<EMBED SRC=\"$path$1.mov\" ALIGN=right $movinfo>/g;
- $temp =~ s/{M\$(\w*)M}/<EMBED SRC=\"$path$1.mov\" ALIGN=absmiddle $movinfo>/g;
- $temp =~ s/{M\!(\w*)M}/<EMBED SRC=\"$path$1.mov\" HIDDEN $movinfo>/g;
-
- $align =~ /\!/ and $align = " HIDDEN=\"true\"";
-
-
- if (($x = index($temp,"{")) > -1 || ($x = index($temp,"}")) > -1)
- {
- $part = substr($temp,$x-3,12);
- print "WARNING: This file contains unrecognized tags! ...$part...\n";
- }
-
- $temp =~ s/≤/{/gi; # for { and } in output
- $temp =~ s/≥/}/gi;
-
- return $temp;
- }
-
- ### time stamp routine ###
-
- sub timestamp
- {
- @months = ("January","February","March","April","May","June",
- "July","August","September","October","November","December",);
-
- ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-
- # if ($hour < 10) { $zero = "0"; } else { $zero = ""; }
- # return "$months[$mon] $mday, 19$year at $zero$hour$min";
-
- if ($hour > 11) { $mm = "PM"; } else { $mm = "AM"; }
-
- if ($hour > 12) { $hour -= 12; }
-
- if ($hour < 1) { $hour = 12; }
-
- if ($min < 10) { $min = "0" . $min; }
-
- return "$months[$mon] $mday, 19$year";
-
- # return "$months[$mon] $mday, 19$year at $hour:$min $mm";
- }
-